
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[ReportBaseObjectInsert]
    @Id INT OUTPUT ,
    @BookmarkId INT ,
    @IsGroup BIT ,
    @Name VARBINARY(MAX) ,
    @Visible BIT
AS 
    BEGIN
    
        DECLARE @WordBookmarkId INT
        DECLARE @BookmarkGroupId INT

        IF ( @IsGroup = 1 ) 
            BEGIN
                SET @WordBookmarkId = NULL
                SET @BookmarkGroupId = @BookmarkId
            END
        ELSE 
            BEGIN
                SET @WordBookmarkId = @BookmarkId
                SET @BookmarkGroupId = NULL
            END
	
        INSERT  INTO ReportBaseObject
                ( WordBookmarkId ,
                  BookmarkGroupId ,
                  Name ,
                  DateCreated ,
                  Visible ,
                  Deleted
                )
        VALUES  ( @WordBookmarkId ,
                  @BookmarkGroupId ,
                  @Name ,
                  GETDATE() ,
                  @Visible ,
                  0
                ) ;
	
        SET @Id = SCOPE_IDENTITY() ;
	
    END
GO
